<?php
/**
 * Created by PhpStorm.
 * User: fanzhaogui
 * Date: 2021/3/29
 * Time: 11:39
 */

namespace APP\Exception;


use EasySwoole\EasySwoole\Logger;
use EasySwoole\Trigger\Location;
use EasySwoole\Trigger\TriggerInterface;

/**
 * 自定义异常类
 *
 * @important**如需使用： 在initialize事件中注入自定义trigger处理器：**
 * \EasySwoole\EasySwoole\Trigger::getInstance(new \App\Exception\TriggerHandel());
 *
 * Class TriggerHandel
 * @package APP\Exception
 */
class TriggerHandel implements TriggerInterface
{
    public function error($msg, int $errorCode = E_USER_ERROR, Location $location = null)
    {
        Logger::getInstance()->console('这是自定义输出的错误:'.$msg);
    }


    public function throwable(\Throwable $throwable)
    {
        Logger::getInstance()->console('这是自定义输出的异常:'.$throwable->getMessage());
    }
}